*********************************************************
*********************************************************  
*** GBR 2024 --- JPE Revision Package *******************
*** Code to prepare the dataset of Study 2 **************
*** Public (anonymized) *********************************
*********************************************************
 
** Note: this code is use for cleaning the dataset for Study 2 for it being
* used together with the datasets of Studies 1 and 3. It has been already 
* pre-cleaned before, including for anonymization.

clear all
use ".../JPEReplicationPackageDataverse/GBR24DataStudy2.dta"

set more off

destring, replace

** Create control variables
* Age categories (age variable from Prolific)
gen age60=0  if age!=.
replace age60=1 if age>=60 & age!=.
gen age50=0 if age!=.
replace age50=1 if age>=50 & age<60
gen age40=0  if age!=.
replace age40=1 if age>=40 & age<50
label variable age40 "Age 40-49 indicator: 0No 1Yes"
label variable age50 "Age 50-59 indicator: 0No 1Yes"
label variable age60 "Age 60+ indicator: 0No 1Yes"

* Ethnicity: no ethnicity data from Prolific for Study 2
gen white=.
label variable white "White (vs. non-white) indicator: 0No 1Yes"

* Re-code and re-scale questionnaire questions post experiment, common Studies 1--3
* PE1, understand instructions
gen PE1_UnderstandInst=PE1-1
label variable PE1_UnderstandInst "Common: Understood instructions scale: 0 (not at all) to 6 (very well)"
* PE3, trust instructions
gen PE3_TrustInst=PE3-1
label variable PE3_TrustInst "Common: Trusted instructions scale: 0 (not at all) to 6 (completely)"
* PE4, discussed study before participating
gen PE4_DiscussSomeoneElse=PE4-1
label variable PE4_DiscussSomeoneElse "Common: Discussed study with other Prolific user who participated before study: 0No 1Yes"
* PE5, helped by someone else
gen PE5_HelpSomeoneElse=PE5-1
label variable PE5_HelpSomeoneElse "Common: Completed this study with the help of someone else: 0No 1Yes"
* PE6, participated in similar experiment before
gen PE6_ParticipatedSimilarExp=PE6-1
label variable PE6_ParticipatedSimilarExp "Common: Participated in similar experiment before: 0No 1Yes"
* PE7, knew someone else participating in same experiment
gen PE7_KnowSomeoneElse=PE7-1
label variable PE7_KnowSomeoneElse "Knew someone participating in same experiment: 0No 1Yes"
* PE9, believe gender discrimination was used in the study
gen PE9_UsedDiscrimination=PE9-1
label variable PE9_UsedDiscrimination "Believed gender discr was used in study: 0 (not at all) to 6 (completely)"
* PE10, believed could reward experimenters by completing more lines or hurt them by completing fewer lines
gen PE10_BeliefReward_withmorelines=PE10-1
label variable PE10_BeliefReward_withmorelines "Believed reward experimenter with lines: 0 (not at all) to 6 (completely)"
* PE11, believed other (paired) participant exists
gen PE11_BelOtherExists=PE11-1
label variable PE11_BelOtherExists "Believed other (paired) participant exists: 0 (not at all) to 6 (completely)"
* PE12, previous experience of discrimination (outside experiment, PE12:6 means participant did not want to answer)
gen PE12_PreviouslyDiscriminated=PE12-1 if PE12!=6
label variable PE12_PreviouslyDiscriminated "Previous experience of gender disc: 0 (not at all) to 4 (a great deal)"
* PE13, previous experience of discrimination in workplace (PE13:6 means participant did not want to answer)
gen PE13_PreviouslyDiscriminatedWork=PE13-1 if PE13!=6 
label variable PE13_PreviouslyDiscriminatedWork "Previous workplace experience of gender disc: 0 (not at all) to 4 (a great deal)"
* PE14, belief how much women earn vs. men, on average in UK for full-time job
gen PE14_GenderEarningGapOverall=PE14-1 if PE14!=16 & PE14!=17
label variable PE14_GenderEarningGapOverall "Belief wom earn vs man, fulltime job: 0(65%-) 7(100%) 14(135%+)"
* PE15, belief how much women earn vs. men doing the same full-time job with the same work characteristics (e.g., competence, education, hours worked, management skills, productivity), on average in UK
gen PE15_GenderEarningGapSameWorkers=PE15-1 if PE15!=16 & PE15!=17
label variable PE15_GenderEarningGapSameWorkers "Belief wom earn vs man w/ same charact, fulltime job: 0(65%-) 7(100%) 14(135%+)"
* PE16, belief regarding how much gender disc there is in UK today
gen PE16_BeliefGenderDiscUKToday=PE16-1 if PE16!=8 & PE16!=9
label variable PE16_BeliefGenderDiscUKToday "UK gender disc today: 0(men strong disc against)-6(wom strong disc against)"
* PE17, for or against preferential hiring and promotion of women
gen PE17_PreferentialTreatmentWom=PE17-1 if PE17!=6 & PE17!=7
label variable PE17_PreferentialTreatmentWom "Preferential hiring/promotion of wom: 0(strong against)-4(strong for)"
* PE18, agree or disagree that both husband and wife should contribute to household income
gen PE18_HusbWifeShouldContInc=PE18-1 if PE18!=6 & PE18!=7
label variable PE18_HusbWifeShouldContInc "Both husband/wife should contribute to hous inc: 0(strong disag)-4(strong agree)"
* PE19, agree or disagree that job is alright, but what most women really want is home and children
gen PE19_WomWantHomeChildren=PE19-1 if PE19!=6 & PE19!=7
label variable PE19_WomWantHomeChildren "What wom really want is home+children: 0(strong disag)-4(strong agree)"
* PE20, agree or disagree that most men are better suited emotionally for politics than are most women
gen PE20_MenBetterSuitedPolitics=PE20-1 if PE20!=6 & PE20!=7
label variable PE20_MenBetterSuitedPolitics "Men better suited emotionally for politics: 0(strong disag)-4(strong agree)"

* Create indicator for UK nationality
gen nat_uk=0 if nationality!="United Kingdom" & nationality!=""
replace nat_uk=1 if nationality=="United Kingdom" 
label variable nat_uk "Nationality indicator: 0Non-UK 1UK"

* Create indicator for students
gen student=0 if student_status=="No"
replace student=1 if student_status=="Yes"
label variable student "Student indicator: 0No 1Yes"

* Create employment status indicators
gen employed=.
replace employed=1 if employment_status=="Full-Time"
replace employed=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace employed=0 if employment_status=="Other"
replace employed=0 if employment_status=="Part-Time"
replace employed=0 if employment_status=="Unemployed (and job seeking)"
label variable employed "E: Employed full time indicator: 0No 1Yes"

gen unemployed=.
replace unemployed=0 if employment_status=="Full-Time"
replace unemployed=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace unemployed=0 if employment_status=="Other"
replace unemployed=0 if employment_status=="Part-Time"
replace unemployed=1 if employment_status=="Unemployed (and job seeking)"
label variable unemployed "E: Unemployed indicator: 0No 1Yes"

gen parttime=.
replace parttime=0 if employment_status=="Full-Time"
replace parttime=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace parttime=0 if employment_status=="Other"
replace parttime=1 if employment_status=="Part-Time"
replace parttime=0 if employment_status=="Unemployed (and job seeking)"
label variable parttime "E: Employed part time indicator: 0No 1Yes"

gen notInPaidJob=.
replace notInPaidJob=0 if employment_status=="Full-Time"
replace notInPaidJob=1 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace notInPaidJob=0 if employment_status=="Other"
replace notInPaidJob=0 if employment_status=="Part-Time"
replace notInPaidJob=0 if employment_status=="Unemployed (and job seeking)"
label variable notInPaidJob "E: Not in paid job indicator: 0No 1Yes"

gen otheremployment=.
replace otheremployment=0 if employment_status=="Full-Time"
replace otheremployment=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace otheremployment=1 if employment_status=="Other"
replace otheremployment=0 if employment_status=="Part-Time"
replace otheremployment=0 if employment_status=="Unemployed (and job seeking)"
label variable otheremployment "E: Other employement status indicator: 0No 1Yes"


** Create variable to identify each study, and ID variable (2,000,000 range 
* denotes IDs in Study 2)
gen study=2
gen id=2000000 + _n
label variable study "Study: 1Study1 2Study2 3Study3 4Study4 5Study5 6Study6"
label variable id "Worker ID: 1,000,000 range for Study 1, 2,000,000 for Study 2,..."

** Create alternative wage variable
gen w=3 if low_wage==1
replace w=6 if high_wage==1
label variable w "Piece-rate wage in approx. 2018 equivalent: 3(low-wage) 6(high-wage)"

** Create inequality aversion variables (for parameter estimation in Appendix)
gen dis_ineq=0 
replace dis_ineq=6-3 if low_unequal==1
label variable dis_ineq "Disadvantageous piece-rate wage inequality"
gen adv_ineq=0
replace adv_ineq=6-3 if high_unequal==1
label variable adv_ineq "Advantageous piece-rate wage inequality"
gen d_dis_ineq=0 
replace d_dis_ineq=6-3 if low_disc==1
label variable d_dis_ineq "Gender-disc disadvantageous piece-rate wage inequality"
gen d_adv_ineq=0
replace d_adv_ineq=6-3 if high_disc==1
label variable d_adv_ineq "Gender-disc advantageous piece-rate wage inequality"


* Standardize labor supply based on unequal low wage scheme (mean 47.69057, sd 28.59677)
sum l if low_unequal==1 & study==2
gen sd_l=(l-47.69057)/28.59677 if study==2
label variable sd_l "Standardized labor supply (based on UnEq low-wage workers)"

* Standardize labor supply by gender based on unequal low wage scheme of each gender (men: mean 46.72932, sd 29.73701; women: mean 48.65909, sd 27.4793)
sum l if low_unequal==1 & study==2 & woman==0
sum l if low_unequal==1 & study==2 & woman==1
gen sd_l_gender=(l-46.72932)/29.73701 if study==2 & woman==0
replace sd_l_gender=(l-48.65909)/27.4793 if study==2 & woman==1
label variable sd_l_gender "Gender-standardized labor supply (based on UnEq low-wage workers of each gender)"


* Provide info in label for three comprehension questions
label variable C2  "1st ans. to compr. quest. on what the task is, correct:3"
label variable C4 "1st ans. to compr. quest. on whether task has further uses for anyone, correct:4"
label variable C9 "1st ans. to compr. quest. on how we pay workers, correct:3"


** Save dataset
save ".../JPEReplicationPackageDataverse/GBR24DataCleanStudy2.dta", replace
